


******************************************************************************
* Kuttner monetary policy shocks
******************************************************************************
	//Kuttner shock: Daily surprise change in 1st fed funds futures contract on FOMC meetings days
	
*************************
* Files from Kenneth Kuttner's website
*************************	
	
import excel "../data/kuttner_shocks/raw_data/Kuttner website/Daily FF surprises June 2019.xlsx", clear firstrow

rename A date
format date %td
rename Surprise kuttner_shock
keep date kuttner_shock
drop if missing(date)

tempfile original_kuttner
save	`original_kuttner'

//Data ends in 19jun2019, continue with Bloomberg futures thereafter

*************************
* Bloomberg fed funds futures
*************************

*Load the fed funds futures date from Bloomberg
import excel "../data/kuttner_shocks/raw_data/Bloomberg_fed_funds_futures.xlsx", cellrange("A3") firstrow clear

format date %td
drop B
drop if missing(date)
drop if fut1_id == "#N/A Field Not Applicable"

*Destring
destring *, replace ignore("#N/A N/A")

*Drop observation where the first Fed funds futures contract has no price
drop if missing(fut1_px)

*Compute daily changes
sort date
generate chg_fut1_px = fut1_px - fut1_px[_n-1] if fut1_id == fut1_id[_n-1]
replace chg_fut1_px = fut1_px - fut2_px[_n-1] if missing(chg_fut1_px)

keep date chg_fut1_px

*Choose sample period
keep if date >= mdy(7,1,2019)
keep if date <= mdy(7,1,2021)

*obtain the FOMC meeting dates
preserve 
	import delimited "../data/fomc_dates/raw_data/FOMC_meeting_dates.csv", clear

	*Format date
	rename date date_help
	gen date=date(date_help, "MDY")
	format date %td
	order date
	drop date_help
	
	*Choose sample period
	keep if date >= mdy(7,1,2019)
	keep if date <= mdy(7,1,2021) //Choose sample period
	
	keep date fomc_meet
	
	tempfile fomc_meetings
	save	`fomc_meetings'
restore 

**Merge data
merge 1:1 date using `fomc_meetings'
tab date if _merge == 2 //15Mar2020 (Sunday)
drop _merge
sort date 

*Use the observation from the following Monday for March 15, 2020
replace chg_fut1_px = chg_fut1_px[_n+1] if date == td(15Mar2020)

keep if fomc_meet == 1
drop fomc_meet

*************************
* Merge the shock series
*************************

append using `original_kuttner'
sort date 

*Generate negative Kuttner shock
generate neg_kuttner = (kuttner_shock < 0) if !missing(kuttner_shock)
replace neg_kuttner = (chg_fut1_px > 0) if missing(neg_kuttner) //Inverse since futures contract: 100 - rate

keep date neg_kuttner

label variable neg_kuttner  "Kuttner monetary policy shocks"

compress 
save "../data/kuttner_shocks/clean_data/kuttner_shocks.dta", replace